<div class="d-flex justify-content-center">
  <div class="col-8">
    <form name="editForm" novalidate (ngSubmit)="save()" [formGroup]="editForm">
      <h2
        id="jhi-label-heading"
        data-cy="LabelCreateUpdateHeading"
        jhiTranslate="jhipsterSampleApplicationApp.label.home.createOrEditLabel"
      >
        Create or edit a Label
      </h2>

      <div>
        <jhi-alert-error />

        @if (editForm.controls.id.value !== null) {
          <div class="mb-3">
            <label class="form-label" for="field_id" jhiTranslate="jhipsterSampleApplicationApp.label.id">ID</label>
            <input type="number" class="form-control" name="id" id="field_id" data-cy="id" formControlName="id" [readonly]="true" />
          </div>
        }

        @let labelRef = editForm.get('label')!;
        <div class="mb-3">
          <label class="form-label" for="field_label" jhiTranslate="jhipsterSampleApplicationApp.label.label">Label</label>
          <input type="text" class="form-control" name="label" id="field_label" data-cy="label" formControlName="label" />
          @if (labelRef.invalid && (labelRef.dirty || labelRef.touched)) {
            <div>
              @if (editForm.get('label')?.errors?.required) {
                <small class="form-text text-danger" jhiTranslate="entity.validation.required">This field is required.</small>
              }
              @if (editForm.get('label')?.errors?.minlength) {
                <small class="form-text text-danger" jhiTranslate="entity.validation.minlength" [translateValues]="{ min: '3' }"
                  >This field is required to be at least 3 characters.</small
                >
              }
            </div>
          }
        </div>

        <div class="mb-3">
          <label for="field_operations" jhiTranslate="jhipsterSampleApplicationApp.label.operation">Operation</label>
          <select
            class="form-control"
            id="field_operations"
            data-cy="operation"
            multiple
            name="operations"
            formControlName="operations"
            [compareWith]="compareOperation"
          >
            @for (operationOption of operationsSharedCollection(); track $index) {
              <option [ngValue]="operationOption">{{ operationOption.id }}</option>
            }
          </select>
        </div>
      </div>

      <div>
        <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" (click)="previousState()">
          <fa-icon icon="ban" />&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
        </button>

        <button
          type="submit"
          id="save-entity"
          data-cy="entityCreateSaveButton"
          [disabled]="editForm.invalid || isSaving"
          class="btn btn-primary"
        >
          <fa-icon icon="save" />&nbsp;<span jhiTranslate="entity.action.save">Save</span>
        </button>
      </div>
    </form>
  </div>
</div>
